<!-- pass a variable to included page -->
<%@ page import="instructor.sample.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<% 
   String today = null;
   Today t = new Today();
   today = t.getToday();
   request.setAttribute("picture","Customer");
   request.setAttribute("title", "Customer Home"); 
   request.setAttribute("header", "Welcome " + 
   		session.getAttribute("firstname") + " " + 
   		session.getAttribute("lastname") + " from " + 
   		session.getAttribute("customername") + " : Today is " + today); 
 %>
 <%@ include file="header.jsp"%><TD width="850" vAlign="top"> 
<br /><h2>Open Service Requests</h2><br />
			<table width=100% border=0 cellpadding=3 cellspacing=3>
			<tr>
				<th bgcolor="#3B73B9" style="text-align:center; color:white;">Service Order</th>
				<th bgcolor="#3B73B9" style="text-align:center; color:white;">Equipment Nbr</th>
				<th bgcolor="#3B73B9" style="text-align:center; color:white;">Product</th>
				<th bgcolor="#3B73B9" style="text-align:center; color:white;">Service Type</th>
				<th bgcolor="#3B73B9" style="text-align:center; color:white;">Status</th>
			</tr>
 <%
 int customerid=0;
try	{
 	customerid = Integer.parseInt((session.getAttribute("customerid")+ ""));
	}
catch (Exception ex){
	response.sendRedirect("engineerhome.jsp");
	}
 
 ResultSet rs = null;
 String rowcolor = "whitesmoke";
 String textcolor = "black";
 String myRowColor = rowcolor;
 
 Customer c = new Customer();
 rs = c.getOpenRequests(customerid);
 
 while (rs.next()) {
  %>
			
	<tr>
	<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT> <a href="sodetails.jsp?serviceorderid=<%=rs.getString("serviceorderid")%>"><%=rs.getString("serviceorderid")%></a></td>
	<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT> <a href="equipmentdetails.jsp?equipmentid=<%=rs.getString("equipmentid")%>"><%=rs.getString("equipmentid")%></a></td>
	<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;">&nbsp;<%=rs.getString("productname")%>&nbsp;</td>
	<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;">&nbsp;<%=rs.getString("servicetypedescription")%>&nbsp;</td>
	<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;">&nbsp;<%=rs.getString("soStatusDescription")%>&nbsp;</td>
	</tr>
			
			
  <%
       
      if (rowcolor.equals(myRowColor)) {
      		rowcolor = "white";
     		textcolor = "black";
 		 }
  		else   {
      		rowcolor = myRowColor;
      		textcolor = "black";
  		}
    }
 rs.close();  
 c.closeConnection();
 %>
 
</table><hr><br />

<h4>Preventive Maintenance Due Within 30 Days</h4>
<table width=100% border=0 cellpadding=3 cellspacing=3>
  		<tr>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">&nbsp;Equipment&nbsp;Nbr&nbsp;</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Product</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Maintenance</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Frequency</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Last Service</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Service Due</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Remaining</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Service Order?</th>
  		</tr>
   <% 		
  		
  	rs = c.getDueSoon(customerid);
  	rowcolor = "whitesmoke";
    textcolor = "black";
    myRowColor = rowcolor;
  	String strongon = "&nbsp;";
  	String strongoff = "&nbsp;";
  	String lasttextcolor="black";
  	while (rs.next()) {
  	if (Integer.parseInt(rs.getString("DaysUntilDue")) < 10 ){
  	    lasttextcolor = "FF0000";
  	    strongon="<strong>";
  	    strongoff="</strong>";
  	    }
  %>
			
		<tr>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT><a href="equipmentdetails.jsp?equipmentid=<%=rs.getString("equipmentid")%>"><%=rs.getString("equipmentid")%></a></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("productname")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("pmdescription")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("frequency")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("LastService")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("ServiceDue")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=lasttextcolor%>;"><%=strongon%><%=rs.getString("DaysUntilDue")%><%=strongoff%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT> <a href="newso.jsp?equipmentid=<%=rs.getString("equipmentid")%>&&pm=true">Create</a></td>
		</tr>		
			
  <%
       
      if (rowcolor.equals(myRowColor)) {
      		rowcolor = "white";
 		 }
  		else   {
      		rowcolor = myRowColor;
  		}
  		
  	strongon = "&nbsp;";
  	strongoff = "&nbsp;";
  	lasttextcolor="black";
  		
    }
 rs.close();  
 c.closeConnection();
      
  %> 		
  
</table><hr /><br />
<h4>Preventive Maintenance Past Due</h4>
<table width=100% border=0 cellpadding=3 cellspacing=3>
  		<tr>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">&nbsp;Equipment&nbsp;Nbr&nbsp;</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Product</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Maintenance</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">&nbsp;Frequency&nbsp;</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Last Service</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">&nbsp;Service Due&nbsp;</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Past Due</th>
  			<th bgcolor="#3B73B9" style="text-align:center; color:white;">Service Order?</th>
  		</tr>
 		
  <% 		
  		
  	rs = c.getOverDuePM(customerid);
  	rowcolor = "whitesmoke";
    textcolor = "black";
    myRowColor = rowcolor;
  	strongon = "&nbsp;";
  	strongoff = "&nbsp;";
  	lasttextcolor="black";
  	while (rs.next()) {
  	if (Integer.parseInt(rs.getString("DaysOverDue")) > 90 ){
  	    lasttextcolor = "FF0000";
  	    strongon="<strong>";
  	    strongoff="</strong>";
  	    }
  %>
		
		<tr>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT> <a href="equipmentdetails.jsp?equipmentid=<%=rs.getString("equipmentid")%>"><%=rs.getString("equipmentid")%></a></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("productname")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("pmdescription")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><%=rs.getString("frequency")%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;">&nbsp;<%=rs.getString("LastService")%>&nbsp;</td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;">&nbsp;<%=rs.getString("ServiceDue")%>&nbsp;</td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=lasttextcolor%>;"><%=strongon%><%=rs.getString("DaysOverDue")%><%=strongoff%></td>
			<td bgcolor=<%=rowcolor%> style="text-align:center; color:<%=textcolor%>;"><FONT color="#ff0066">&gt;</FONT> <a href="newso.jsp?equipmentid=<%=rs.getString("equipmentid")%>&&pm=true">Create</a></td>
		</tr>
			
  <%
       
      if (rowcolor.equals(myRowColor)) {
      		rowcolor = "white";
 		 }
  		else   {
      		rowcolor = myRowColor;
  		}
  		
  	  strongon = "&nbsp;";
  	  strongoff = "&nbsp;";
  	  lasttextcolor="black";
  		
    }
 rs.close();  
 c.closeConnection();
      
  %>
  
  </table><hr />
 
  </table></html>
  		
  		
  		
  		
  		